<div class="mt20 clearfix ng-scope ml25">
    <span class="fl lh30 f14">发票信息</span>
    <div class="fr btn-group"
         ng-if="contractBaseInfo.contract_status == 2 && contractBaseInfo.is_cancelled == 0 && !areaRole"
         ng-show="userAuthList.indexOf('0201') !== -1">
        <button>{{remainInvoiceAmount}}</button>
        <button href="javascript:;" class="btn" id="addVoiceButton"
                ui-dialog="新增发票"
                ui-dialog-data="{}"
                ui-dialog-show="receivableInvoiceService.onInvoiceEditShow(contractBaseInfo.contract_id,$dialog,$dialogScope, 1,null,contractBaseInfo,receivableInfo.invoices)"
                ui-dialog-ok="receivableInvoiceService.editInvoiceSave($data,$dialog,$dialogScope,reloadInvoices,contractBaseInfo,1)"
                ui-dialog-on-close="receivableInvoiceService.onCloseInvoice($dialogScope,1)"
                ui-dialog-cache="false"
                ui-dialog-url="${require('./receivable-inc-edit-invoice.html?url')}"
        >新增发票
        </button>
        <button href="javascript:;" class="btn"
                ui-dialog="新增子发票"
                ui-dialog-data="{}"
                ui-dialog-show="receivableInvoiceService.onInvoiceEditShow(contractBaseInfo.contract_id,$dialog,$dialogScope, 2,null,contractBaseInfo,receivableInfo.invoices)"
                ui-dialog-ok="receivableInvoiceService.editInvoiceSave($data,$dialog,$dialogScope,reloadInvoices,contractBaseInfo,1)"
                ui-dialog-cache="false"
                ui-dialog-url="${require('./receivable-inc-edit-invoice.html?url')}"
        >新增子发票
        </button>
        <button href="javascript:;" class="btn"
                ui-dialog="新增收据"
                ui-dialog-data="{}"
                ui-dialog-show="receivableInvoiceService.onInvoiceEditShow(contractBaseInfo.contract_id,$dialog,$dialogScope, 4,null,contractBaseInfo,receivableInfo.invoices)"
                ui-dialog-ok="receivableInvoiceService.editInvoiceSave($data,$dialog,$dialogScope,reloadInvoices,contractBaseInfo,1)"
                ui-dialog-cache="false"
                ui-dialog-url="${require('./receivable-inc-edit-invoice.html?url')}"
        >新增收据
        </button>
    </div>
</div>
<div id="grid" class="table-wrap mt10 ml25" style="min-height: 200px;">

    <table width="100%" class="valign-t">
        <thead>
        <tr>
            <th width="35">序号</th>
            <th width="150">发票信息</th>
            <th width="70">开票金额</th>
            <th>开票单位</th>
            <th width="160">客户名称</th>
            <th width="70">对应回款</th>
            <th width="70">已回款金额</th>
            <th width="100">附加信息</th>
            <th width="80">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="record in receivableInfo.invoices" ng-if="record.__isdelete != 1">
            <td height="40"><p ng-bind="$index + 1"></p></td>
            <td class="lh14">
                <p>{{record.is_receipt==1?'收据':'发票'}}代码:{{record.invoice_code}}</p>

                <p class="c-gray">{{record.is_receipt==1?'收据':'发票'}}号码:{{record.invoice_no}}</p>
            </td>
            <td>
                <p ng-bind="record.invoice_amount | number:2"></p>
            </td>
            <td>
                <p>{{record.BUName}}</p>

                <p class="c-gray">开票时间:{{record.invoice_date | strdate:'yyyy-MM-dd'}}</p>
            </td>
            <td>
                <p ng-bind="record.customer_name"></p>
            </td>
            <td>
                <p ng-bind="record.receivables_amount|number:2"></p>
            </td>
            <td>
                <p ng-bind="record.payment_amount|number:2"></p>
            </td>
            <td>
                <p>{{ record.is_red_invoice == 1 ? '红冲发票' : record.is_reded_invoice == 1 ? '被红冲发票' : '正常发票'}}</p>
                <p>是否遗失:{{ record.is_lose == 1 ? '是' : '否' }}</p>
                <p>是否收据:{{ record.is_receipt == 1 ? '是' : '否' }}</p>
            </td>

            <td>
                <div ng-if="contractBaseInfo.contract_status == 2 && contractBaseInfo.is_cancelled == 0"
                     ng-show="userAuthList.indexOf('0201') !== -1">
                    <a type='edit' href="javascript:;"
                       ui-dialog="编辑发票"
                       ui-dialog-data="{}"
                       ui-dialog-show="receivableInvoiceService.onInvoiceEditShow(contractBaseInfo.contract_id,$dialog,$dialogScope, 1,record,contractBaseInfo,remainInvoiceAmount)"
                       ui-dialog-ok="receivableInvoiceService.editInvoiceSave($data,$dialog,$dialogScope,reloadInvoices,contractBaseInfo,0)"
                       ui-dialog-on-close="receivableInvoiceService.onCloseInvoice($dialogScope,1)"
                       ui-dialog-cache="false"
                       ui-dialog-url="${require('./receivable-inc-edit-invoice.html?url')}"
                    >编辑
                    </a>
                    <a href="javascript:void(0)" class="clearfix"
                       title="删除{{record.is_receipt==1?'收据':'发票'}}"
                       ng-click="receivableInvoiceService.deleteInvoice(record,reloadInvoices)">删除</a>
                    <a type='edit'
                       ui-dialog="解除发票与回款的绑定"
                       ui-dialog-url="${require('./receivable-inc-edit-unbind-payment.html?url')}"
                       ui-dialog-before-show="receivableInvoiceService.beforeUnbindPaymentForInvoice($dialog, $dialogScope, record)"
                       ui-dialog-ok="receivableInvoiceService.unbindPaymentForInvoice($data, reloadInvoices)"
                       ng-style="{display: 'inline-block'}"
                       ng-hide="record.payment_amount == '0.00'"
                    >解绑回款
                        <a href="javascript:void(0)" class="clearfix"
                           title="红冲发票"
                           ui-dialog="新增红冲发票"
                           ui-dialog-data="{isHongChongInvoice: true}"
                           ui-dialog-show="receivableInvoiceService.onInvoiceEditShow(contractBaseInfo.contract_id,$dialog,$dialogScope, 3,record,contractBaseInfo)"
                           ui-dialog-ok="receivableInvoiceService.editInvoiceSave($data,$dialog,$dialogScope,reloadInvoices,contractBaseInfo)"
                           ui-dialog-cache="false"
                           ui-dialog-url="${require('./receivable-inc-edit-invoice.html?url')}"
                           ng-if="record.is_reded_invoice == 0 && record.is_red_invoice == 0"
                        >红冲此发票</a>
                        <a href="javascript:void(0)" class="clearfix"
                           title="转为发票"
                           ng-if="record.is_receipt == 1"
                           ng-click="receivableInvoiceService.convertToInvoice(record,$event)">转为发票</a>
                </div>

            </td>
        </tr>
        </tbody>
    </table>
    <div class="no-data" ng-if="invoices.length == 0" style="height:180px"><span>暂无数据</span></div>

</div>

<div class="ml25 mt10">
    <span class="pl10">说明：收入金额(<em class="b">{{contractBaseInfo| signOrIncomeAmount |number:2}}</em>元) = 已确定发票(<em
            class="b">{{receivableInfo.invoices |sumInvoiceAmount|number:2}}</em>元) + 未确定发票(<em class="b c-red">{{
        receivableInfo.invoices | remainInvoiceAmount:contractBaseInfo |number:2}}</em>元)</span>
</div>
